package day240602;

import java.util.*;

public class MapDemo2 {
    public static void main(String[] args) {
        // HashMap Since: 1.2
        Map<String, String> map1 = new HashMap<>();
        map1.put("k1", null);
        map1.put(null, "v1");
        System.out.println(map1);


        // Hashtable 典型的官方命名就就规范的例子 Since: 1.0
        // synchronized 线程安全，性能较低。类似于 StringBuffer vs StringBuilder，又不全一样，把 Hashtable 当成淘汰的类
        // If a thread-safe implementation is not needed, it is recommended to use HashMap in place of Hashtable. If a thread-safe highly-concurrent implementation is desired, then it is recommended to use java. util. concurrent. ConcurrentHashMap in place of Hashtable.
        Map<String, String> map2 = new Hashtable<>();
        map2.put("k1", null);
        map2.put(null, "v2");
        System.out.println(map2);
    }
}
